<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>注册信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../layui-v2.6.8/layui/css/layui.css">
    <script type  ="text/javascript" src="../layui-v2.6.8/layui/layui.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->

    <style>
        .login-form {
            position: absolute;
            top: 30%;
            -webkit-transform: translateY(-50%);
            -moz-transform: translateY(-50%);
            -ms-transform: translateY(-50%);
            -o-transform: translateY(-50%);
            transform: translateY(-50%);
            min-height: 300px;
            height: auto;
        }
        body{
            background: url(img/02.jpg) no-repeat;
            background-size:100%;
        }

    </style>
</head>
<body>

<!--<blockquote class="layui-elem-quote layui-text">-->
<!--    鉴于小伙伴的普遍反馈，先温馨提醒两个常见“问题”：1. <a href="/doc/base/faq.html#form" target="_blank">为什么select/checkbox/radio没显示？</a> 2. <a href="/doc/modules/form.html#render" target="_blank">动态添加的表单元素如何更新？</a>-->
<!--</blockquote>-->

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>注册信息</legend>
</fieldset>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" id="cname" name="acontact" required  lay-verify="required" placeholder="姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-block">
            <input type="text" id="cphone" required  lay-verify="required" placeholder="电话" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-block">
            <input type="text" id="user_name" required  lay-verify="required" placeholder="账号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" id="password" required  lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-input-block">
        <button class="layui-btn" onclick="insert_1()" >注册</button>
    </div>
    </div>
    <table class="layui-hide" id="customer" lay-filter="operation"></table>
</form>
<script src="../layui-v2.6.8/layui/layui.js"></script>
<script type="text/javascript">

    function insert_1(){
        var $ = layui.$;
        var cname =$("#cname").val();
        var cphone =$("#cphone").val();
        var user_name =$("#user_name").val();
        var password =$("#password").val();
        console.log(cname);
        var data ={
            "cname":cname,
            "cphone":cphone,
            "user_name":user_name,
            "password":password,
        }
        var url ="http://localhost:8080/add";
        $.ajax({
            type:"get",
            url:url,
            async:false,
            cache:false,
            data:data,
            success: function(data,textStaus,jqXHR){

                if(data.code === 200){
                    alert("插入成功了");
                }else{
                    alert(data.message);
                }
            },
            error:function (XMLHttpRequest, textStatus, errorThrown) {

                alert(typeof(errorThrown));
            }
        });
    }
</script>
